import java.util.Arrays;
import java.util.Random;

public class Test {
    //顺序
    public static void inorderArray(int[] array) {
        for(int i = 0;i < array.length;i++) {
            array[i] = i;
        }
    }
    //逆序
    public static void notInorderArray(int[] array) {
        for(int i = 0;i < array.length;i++) {
            array[i] = array.length - i;
        }
    }
    //乱序
    public static void initArray(int[] array) {
        Random random = new Random();
        for(int i = 0;i < array.length;i++) {
            array[i] = random.nextInt(array.length);
        }
    }
    public static void testQuickSort(int[] array) {
        int[] tmp = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.quickSort(tmp);
        long endTime = System.currentTimeMillis();
        System.out.println("快速排序:" + (endTime - startTime));
    }
    public static void testMergeSort(int[] array) {
        int[] tmp = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.mergeSort(tmp);
        long endTime = System.currentTimeMillis();
        System.out.println("归并排序:" + (endTime - startTime));
    }

    public static void main1(String[] args) {
        int[] array = new int[20000];
//        initArray(array);
        inorderArray(array);
//        notInorderArray(array);
        testQuickSort(array);
        testMergeSort(array);
    }
    public static void main(String[] args) {
        int[] array = {33,5,2,10,9,8,17};
        Sort.quickSort(array);
//        Sort.quickSortNor(array);
//        Sort.mergeSort(array);
//        Sort.mergeSortNor(array);
//        int[] array = {2,3,6,4,2,3,3,5,9,7};
//        Sort.countSort(array);
        System.out.println(Arrays.toString(array));
    }
}
